//
//  BHHomeCityModel.swift
//  BigHealth
//
//  Created by 蔺百好 on 2021/6/9.
//

import Foundation

class BHHomeCityModel {
    var code: String = "" // 省份code
    var parentCode: String = ""
    var name: String = ""

    var ifMducg: Int = 0 // 是否是直辖市 1是
    
    // 子节点
    var childArray: [BHHomeCityModel] = []
    
    
    func parseDic(_ dic: [String: Any])  {
        self.code = BHJsonTool.decodeStringFromDic(dic: dic, key: "code")
        self.parentCode = BHJsonTool.decodeStringFromDic(dic: dic, key: "parentCode")
        self.name = BHJsonTool.decodeStringFromDic(dic: dic, key: "name")

        self.ifMducg = BHJsonTool.decodeIntFromDic(dic: dic, key: "ifMducg")
    }
    
    
    static var sortArray: [BHHomeCityModel] {
        get {
            let array: [String] = ["智能排序","离我最近","报名最多","价格最低"]
            var tempArray: [BHHomeCityModel] = []
            
            for (index,name) in array.enumerated() {
                let model = BHHomeCityModel.init()
                model.name = name
                if index != 0 {
                    model.code = "\(index)"
                }
                tempArray.append(model)
            }
            return tempArray
        }
    }
    
    static var sortStadiumArray: [BHHomeCityModel] {
        get {
            let array: [String] = ["智能排序","离我最近","购买最多","价格最低"]
            var tempArray: [BHHomeCityModel] = []
            
            for (index,name) in array.enumerated() {
                let model = BHHomeCityModel.init()
                model.name = name
                model.code = "\(index+1)"
                tempArray.append(model)
            }
            return tempArray
        }
    }
//    1：智能排序 2：离我最近 3：报名最多 4：价格最低
    static var gameSortArray: [BHHomeCityModel] {
        get {
            let array: [String] = ["智能排序","离我最近","报名最多","价格最低"]
            var tempArray: [BHHomeCityModel] = []
            
            for (index,name) in array.enumerated() {
                let model = BHHomeCityModel.init()
                model.name = name
                
                model.code = "\(index+1)"
                tempArray.append(model)
            }
            return tempArray
        }
    }
}
